<template>
  <el-container>
    <el-aside :width="isCollapse?'65px':'200px'">
      <el-menu
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b"
        :collapse="isCollapse"
        :collapse-transition='false'
      >
        <el-menu-item index="1" :style="{width:isCollapse?'65px':'200px'}">
          <i class="el-icon-location"></i>
          <span slot="title">首页</span>
        </el-menu-item>
        <el-submenu index="2" :style="{width:isCollapse?'65px':'200px'}">
          <template slot="title">
            <i class="el-icon-menu"></i>
            <span>内容管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="2-1">发布文章</el-menu-item>
            <el-menu-item index="2-2">内容列表</el-menu-item>
          </el-menu-item-group>
          <el-menu-item-group>
            <el-menu-item index="2-3">评论列表</el-menu-item>
          </el-menu-item-group>
          <el-menu-item-group>
            <el-menu-item index="2-4">素材管理</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-menu-item index="3" :style="{width:isCollapse?'65px':'200px'}">
          <i class="el-icon-location"></i>
          <span slot="title">粉丝管理</span>
        </el-menu-item>
        <el-menu-item index="4" :style="{width:isCollapse?'65px':'200px'}">
          <i class="el-icon-location"></i>
          <span slot="title">账号信息</span>
        </el-menu-item>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header>
        <div class="lt">
          <i :class="isCollapse?'el-icon-s-unfold':'el-icon-s-fold'" @click="isCollapse=!isCollapse"></i>
          <span style="margin-left:10px">江苏传智播客教育科技股份有限公司</span>
        </div>
        <div class="rt">
          <el-input type="text" placeholder="请输入搜索的文章内容">
            <i slot="prefix" class="el-input__icon el-icon-search"></i>
          </el-input>
          <span style="margin:0 10px;">消息</span>
          <el-dropdown trigger="click">
            <span class="el-dropdown-link">
              <img :src="photo" alt width="30px" height="30px" />
              {{ name }}
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>个人信息</el-dropdown-item>
              <el-dropdown-item>git地址</el-dropdown-item>
              <el-dropdown-item @click.native="logout()">退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-header>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  name: 'houtai',
  data () {
    return {
      isCollapse: true
    }
  },
  computed: {
    name () {
      return JSON.parse(window.sessionStorage.getItem('status')).name
    },
    photo () {
      return JSON.parse(window.sessionStorage.getItem('status')).photo
    }
  },
  methods: {
    logout () {
      this.$confirm('确认退出码', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          window.sessionStorage.clear()
          this.$router.push('/login')
        })
        .catch(() => {})
    }
  }
}
</script>

<style lang="less" scoped>
.el-container {
  height: 100%;
  .el-aside {
    background-color: rgb(50, 55, 69);
  }
  .el-header {
    display: flex;
    justify-content: space-between;
    // background-color: rgb(pink);
    padding: 0 10px 0 10px;
    min-width: 1200px;
    .lt {
      height: 100%;
      width: 30%;
      // background-color: rgb(42, 205, 255);
      font-size: 18px;
      display: flex;
      align-items: center;
    }
    .rt {
      height: 100%;
      width: 30%;
      // background-color: rgb(217, 0, 255);
      display: flex;
      justify-content: flex-end;
      align-items: center;
      .el-input {
        width: 300px;
        // height: 34px;
      }
      .el-dropdown-link {
        display: flex;
        align-items: center;
        // justify-content: center;
        img {
          margin-right: 10px;
        }
      }
    }
  }
  .el-main {
    background-color: rgb(242, 243, 245);
  }
}
</style>
